package com.shop.vuedemo.constant;

import lombok.Getter;

/**
 * @author clim
 * @Date 2020-09-23
 * @Description
 * 销售单订单 收货方式 邮寄/自提
 */
@Getter
public enum SaleOrderReceiveTypeEnum {

    /**
     * 邮寄
     */
    MAIL(1L,"邮寄"),

    /**
     *自提
     */
    SELF_EXTRACTION(2L,"自提");


    private Long code;
    private String name;

    SaleOrderReceiveTypeEnum(Long code, String name){
        this.code =  code;
        this.name = name;
    }

    public static String getNameByCode(Long code){
        for(SaleOrderReceiveTypeEnum saleOrderReceiveTypeEnum : SaleOrderReceiveTypeEnum.values()){
            if(saleOrderReceiveTypeEnum.getCode().equals(code)){
                return saleOrderReceiveTypeEnum.getName();
            }
        }
        return "";
    }

    public static Long getCodeByName(String name){
        for(SaleOrderReceiveTypeEnum saleOrderReceiveTypeEnum : SaleOrderReceiveTypeEnum.values()){
            if(saleOrderReceiveTypeEnum.getName().equals(name)){
                return saleOrderReceiveTypeEnum.getCode();
            }
        }
        return null;
    }

}
